Skip to content

fix(init): flash init show usage menu when called without arguments#235

Merged
deanq merged 6 commits intomainfrom
deanq/ae-1544-flash-init-correction
Mar 19, 2026
Merged

fix(init): flash init show usage menu when called without arguments#235
deanq merged 6 commits intomainfrom
deanq/ae-1544-flash-init-correction

Conversation

@deanq
Copy link
Member

@deanq deanq commented Feb 28, 2026

Summary

  • flash init with no arguments now prints the built-in Typer help text and exits instead of silently initializing in the current directory
  • flash init . continues to initialize in the current directory (unchanged)
  • flash init <name> continues to create a new project folder (unchanged)

Before: flash init and flash init . had identical behavior -- both initialized in cwd.
After: flash init shows help text; flash init . is the explicit way to initialize in cwd.

Test plan

  • Added 3 new tests for no-args behavior (exits with code 0, does not create skeleton, prints help with markup disabled)
  • Updated existing test that asserted None creates skeleton (removed -- behavior changed)
  • All init tests pass
  • Full make quality-check passes
  • Manual verification of all three modes: flash init, flash init ., flash init <name>

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the flash init CLI behavior so invoking it without a project argument shows a usage/help panel and exits, making “initialize in current directory” an explicit flash init ..

Changes:

  • Added an early-exit usage panel for flash init when called with no positional argument.
  • Updated init logic so only flash init . initializes the current directory (no longer the default when omitted).
  • Added/updated unit tests to cover the new no-args behavior (exit code, no skeleton creation, usage output).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/runpod_flash/cli/commands/init.py Adds no-args usage panel + exit and adjusts current-directory branching to require ..
tests/unit/cli/commands/test_init.py Adds tests validating no-args exit behavior, output, and that no skeleton is created.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@deanq deanq changed the title fix(init): show usage menu when called without arguments fix(init): flash init show usage menu when called without arguments Mar 2, 2026
Copy link
Contributor

@runpod-Henrik runpod-Henrik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review — PR #235: flash init usage menu

The init.py change is clean — showing usage panel when no args instead of silently initializing in cwd is good UX.

Note: This PR shares a large diff overlap with PRs #221 and #237 (aiohttp session consolidation, api_key_context.py removal, DEFAULT_WORKERS_MIN change, get_api_key() migration). The bugs found in those shared components apply here too:

  1. HIGHAuthorization header sent to presigned S3 URLs in app.py (see PR #221 review)
  2. HIGH — Per-request API key propagation from LB to workers silently removed (see PR #221 review)
  3. HIGHuv pip install fails without active venv in update.py (see PR #237 review, if update.py is included)

The init.py change itself has no issues. Tests cover all three modes (flash init, flash init ., flash init name).

@deanq deanq force-pushed the deanq/ae-1544-flash-init-correction branch 2 times, most recently from dfd74ae to e57fdf5 Compare March 10, 2026 02:51
@deanq deanq force-pushed the deanq/ae-1544-flash-init-correction branch 3 times, most recently from 1a13609 to 45bd8c1 Compare March 17, 2026 20:00
Copy link
Contributor

@KAJdev KAJdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just that one fix and then should be good to go

deanq added 3 commits March 18, 2026 12:47
Previously `flash init` with no arguments silently initialized in the
current directory (same as `flash init .`). Now it shows a usage panel
with examples and exits, matching expected CLI behavior:
- `flash init` prints usage menu
- `flash init .` initializes in current directory
- `flash init <name>` creates new project folder
Replace hand-crafted usage text with ctx.get_help() to prevent drift
when CLI options change. Update argument help text to clarify that '.'
must be explicitly passed for current-directory init.
Syntax error from commit message text accidentally appended to a
docstring in test_init.py, breaking ruff format checks.
@deanq deanq force-pushed the deanq/ae-1544-flash-init-correction branch from c73c85a to d1a240c Compare March 18, 2026 19:49
KAJdev review feedback: Panel(ctx.get_help()) renders an empty panel.
Use console.print(ctx.get_help()) directly instead.
@deanq deanq requested review from Copilot and runpod-Henrik March 18, 2026 21:10
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Typer help strings contain [OPTIONS] which Rich interprets as markup
tags, causing MarkupError or mangled output. Pass markup=False and
highlight=False to console.print. Test updated to verify this.
Copy link
Contributor

@runpod-Henrik runpod-Henrik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1. Implementation — behavior change

Clean change. The None branch was cleanly split from "." — previously if project_name is None or project_name == "." routed both to CWD init; now only "." does. The ctx.get_help() approach is the right Typer idiom: it surfaces the same text as flash init --help, is automatically kept in sync as the command signature changes, and the markup=False, highlight=False flags prevent Rich from misinterpreting brackets in the output as markup.

raise typer.Exit(0) is correct — showing help is not an error, so exit code 0 is right.

2. Tests

Question: no CLI-level test for Typer context injection

All tests call init_command(mock_typer_ctx, ...) directly, bypassing Typer's wiring. The unit tests can't verify that ctx: typer.Context is correctly recognized and injected when invoked as a real CLI command. If something were misconfigured at the app.command() registration level, the unit suite would stay green while the CLI silently broke.

Adding a single CliRunner test covers this:

from typer.testing import CliRunner
from runpod_flash.cli.main import app

def test_no_args_via_cli():
    result = CliRunner().invoke(app, ["init"])
    assert result.exit_code == 0
    assert "flash init" in result.output

This is low risk given that typer.Context injection is well-established, but it's the one gap the current tests leave open.

The three new TestInitCommandNoArgs tests cover the right cases — exit code, no skeleton created, help printed with correct kwargs.

Deleted test (test_init_current_directory_with_none) — correct to remove. Its replacement is TestInitCommandNoArgs, which is clearer.

Nits

  • test_no_args_prints_usage_info checks "flash init" in help_arg but the string comes from the mock fixture ("Usage: flash init [OPTIONS] [PROJECT_NAME]"). The test doesn't explicitly assert that ctx.get_help() was called — mock_typer_ctx.get_help.assert_called_once() would make the intent clearer.
  • The raw --help output is functional but a custom panel with two concrete examples (flash init . and flash init my-project) would be more discoverable for users who don't know the dot convention. Enhancement only — not blocking.

Verdict: PASS WITH NITS

The behavior change is clean and correct. The one meaningful gap is a CLI-level integration test to confirm Typer's context injection. The nits are minor.

🤖 Reviewed by Henrik's AI-Powered Bug Finder

Address Henrik review feedback:
- Add CLI-level test via CliRunner to verify Typer context injection
- Assert ctx.get_help() was called in no-args test
@deanq deanq requested review from Copilot and runpod-Henrik March 18, 2026 21:47
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@deanq
Copy link
Member Author

deanq commented Mar 18, 2026

Addressed feedback from review:

  1. CliRunner integration test added -- test_no_args_via_cli invokes via CliRunner().invoke(app, ["init"]) to verify Typer context injection end-to-end (715c291)
  2. ctx.get_help() assertion added -- mock_typer_ctx.get_help.assert_called_once() now explicitly verifies the help text source (715c291)

Nits noted (custom panel with examples) -- not blocking per review, can follow up separately.

@deanq deanq merged commit 3144d0c into main Mar 19, 2026
8 checks passed
@deanq deanq deleted the deanq/ae-1544-flash-init-correction branch March 19, 2026 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants